home *** CD-ROM | disk | FTP | other *** search
/ Software Vault: The Gold Collection / Software Vault - The Gold Collection (American Databankers) (1993).ISO / cdr50 / mlibv22.zip / DEMO3.BAS < prev    next >
BASIC Source File  |  1993-01-27  |  5KB  |  104 lines

  1. DEFINT A-Z
  2. '******************************** DEMO3.BAS *********************************
  3. '*                                                                          *
  4. '*       Demo on how to use : GetSizeM%                                     *
  5. '*                          : SaveStateM                                    *
  6. '*                          : RestoreStateM                                 *
  7. '*                                                                          *
  8. '* NOTE: In order for this demo to run you must start the QB editor         *
  9. '*     : along with the library MLIBN.QLB  (ie., QB/L MLIBN).               *
  10. '*     :                                                                    *
  11. '*     : IF YOU ARE NOT USING QuickBASIC 4.0 - 4.5 SEE PAGE 2 OF THE MANUAL *
  12. '*     : BEFORE TRYING TO RUN THIS DEMO!                                    *
  13. '*                                                                          *
  14. '****************************************************************************
  15. '                                                '
  16. '$INCLUDE: 'mlib.inc'                            '
  17.                                                  '
  18. DECLARE SUB PrintMsg ()                          '
  19. DECLARE SUB ChangeState ()                       '
  20.                                                  '
  21. SCREEN 0: CLS                                    '
  22.                                                  '
  23. CALL InitPointer(X%)                             'Must initialize the mouse.
  24.                                                  '
  25. CALL ShowPointer                                 '
  26.                                                  '
  27. CALL PrintMsg
  28.  
  29. BSize% = GetSizeM%                               'Get mouse state size, in
  30.                                                  'bytes.
  31. Buffer$ = SPACE$(BSize%)                         'Buffer to hold environment.
  32.                                                  '
  33. CALL SaveStateM(Buffer$, SaveErr%)               'Save the mouse environment.
  34.                                                  '
  35. IF NOT SaveErr% THEN                             '
  36.    CALL HidePointer                              '
  37.    CALL ChangeState                              '
  38.    SCREEN 0                                      '
  39. END IF                                           'NOTE! If Buffer$ is changed
  40.                                                  'in any way now that it holds
  41.                                                  'the mouse environment, you
  42.                                                  'will effectivly lock up
  43.                                                  'your system.
  44.                                                  '
  45. CALL RestoreStateM(Buffer$, RestoreErr%)         'Restore mouse environment
  46.                                                  'to it's original state prior
  47. CALL HidePointer                                 'to calling ChangeState.
  48.                                                  
  49. PRINT "Size of the mouse environment: "; BSize%; " bytes."
  50.  
  51. IF SaveErr% THEN
  52.    PRINT "Error in saving the mouse environment."
  53. ELSE
  54.    PRINT "Mouse environment was successfully saved."
  55. END IF
  56.  
  57. IF RestoreErr% THEN
  58.    PRINT "Error in restoring the mouse environment."
  59. ELSE
  60.    PRINT "Mouse environment was successfully restored."
  61.    PRINT "Pointer should be in the same position"
  62.    PRINT "as it was before we changed screen modes."
  63. END IF
  64.  
  65. CALL ShowPointer: a$ = INPUT$(1): CALL HidePointer
  66.  
  67. END
  68.  
  69. SUB ChangeState
  70.  
  71. SCREEN 9
  72. PRINT "Initializing the mouse..."
  73.  
  74. CALL InitPointer(X%)
  75. LOCATE 1, 1
  76. PRINT "What we have done here is change to a graphics mode and initialized the"
  77. PRINT "mouse (which will alter the mouse state). Now we could use this instance"
  78. PRINT "of the mouse to do what ever we liked. After we are done in here we will"
  79. PRINT "restore the mouse state back to its original settings (SCREEN 0)."
  80. PRINT
  81. PRINT "Press a key to return..."
  82.  
  83. CALL ShowPointer
  84.  
  85. DO: LOOP UNTIL LEN(INKEY$)
  86.  
  87. CALL HidePointer
  88.  
  89. END SUB
  90.  
  91. SUB PrintMsg
  92.  
  93. PRINT "This example demonstrates how to save and restore the mouse environment."
  94. PRINT
  95. PRINT "First move the pointer to a position you will remember. After a key has"
  96. PRINT "been pressed, we will save the mouse driver's environment and call a"
  97. PRINT "subroutine that will alter the state of the mouse."
  98. PRINT
  99. PRINT "Remember the pointer position."           '
  100. PRINT "Press a key to continue.": a$ = INPUT$(1) '
  101.  
  102. END SUB
  103.  
  104.